from abc import ABC, abstractmethod
from typing import List, Optional
from uuid import UUID

from .dto import PermissionCreateDTO, PermissionDTO, PermissionUpdateDTO


class PermissionFacade(ABC):
    """Permission domain facade interface."""

    @abstractmethod
    async def create_permission(
            self, permission_data: PermissionCreateDTO) -> PermissionDTO:
        """Create a new permission."""
        pass

    @abstractmethod
    async def get_permission_by_id(
            self, permission_id: UUID) -> Optional[PermissionDTO]:
        """Get permission by ID."""
        pass

    @abstractmethod
    async def get_permission_by_code(self,
                                     code: str) -> Optional[PermissionDTO]:
        """Get permission by code."""
        pass

    @abstractmethod
    async def get_all_permissions(self) -> List[PermissionDTO]:
        """Get all permissions."""
        pass

    @abstractmethod
    async def update_permission(
            self, permission_id: UUID,
            permission_data: PermissionUpdateDTO) -> Optional[PermissionDTO]:
        """Update permission information."""
        pass

    @abstractmethod
    async def delete_permission(self, permission_id: UUID) -> bool:
        """Delete permission by ID."""
        pass

    @abstractmethod
    async def get_role_permissions(self, role_id: UUID) -> List[PermissionDTO]:
        """Get all permissions of a role."""
        pass

    @abstractmethod
    async def assign_permission_to_role(self, role_id: UUID,
                                        permission_id: UUID) -> bool:
        """Assign a permission to a role."""
        pass

    @abstractmethod
    async def remove_permission_from_role(self, role_id: UUID,
                                          permission_id: UUID) -> bool:
        """Remove a permission from a role."""
        pass
